***************************************************
* Calculation of Bresnahan-Reiss Entry Thresholds *
***************************************************

qui{
    
	margins, expression((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1])) atmeans
	matrix t_monopoly = r(b)*`1'
	matrix se_monopoly = r(V)
	matrix se_monopoly = sqrt(se_monopoly[1,1])*`1'

	margins, expression(((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2]))/2) atmeans
	matrix t_duopoly = r(b)*`1'
	matrix se_duopoly = r(V)
	matrix se_duopoly = sqrt(se_duopoly[1,1])*`1'

	margins, expression(((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2] + _b[/ucc_g3])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2] - _b[/ucc_a3]))/3) atmeans
	matrix t_nfirms3 = r(b)*`1'
	matrix se_f3 = r(V)
	matrix se_f3 = sqrt(se_f3[1,1])*`1'

	margins, expression((((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2]))/2)/((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1]))) atmeans
	matrix t_2f_1f = t_duopoly[1,1]/t_monopoly[1,1]
	matrix se_t21 = r(V)
	matrix se_t21 = sqrt(se_t21[1,1])
	
	margins, expression((((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2] + _b[/ucc_g3])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2] - _b[/ucc_a3]))/3)/(((_b[ucc_f:cms_wage_index]*cms_wage_index + _b[/ucc_g1] + _b[/ucc_g2])/(_b[ucc_v:n_hospitals]*n_hospitals + _b[ucc_v:rural]*rural + _b[ucc_v:income_pc]*income_pc + _b[ucc_v:hispanic]*hispanic + _b[ucc_v:nonhisp_black]*nonhisp_black+ _b[ucc_v:gte_highschool]*gte_highschool  + _b[ucc_v:age_65]*age_65 + _b[ucc_v:uninsured]*uninsured + _b[/ucc_a1] - _b[/ucc_a2]))/2)) atmeans
	matrix t_3f_2f = t_nfirms3[1,1]/t_duopoly[1,1]
	matrix se_t32 = r(V)
	matrix se_t32 = sqrt(se_t32[1,1])
		
}


putexcel `2'2 = t_monopoly[1,1]
putexcel `2'3 = se_monopoly[1,1]
putexcel `2'4 = t_duopoly[1,1]
putexcel `2'5 = se_duopoly[1,1]
putexcel `2'6 = t_nfirms3[1,1]
putexcel `2'7 = se_f3[1,1]
putexcel `2'11 = t_2f_1f[1,1]
putexcel `2'12 = se_t21[1,1]
putexcel `2'13 = t_3f_2f[1,1]
putexcel `2'14 = se_t32[1,1]
